import JSEncrypt from './jsencrypt.js';
// 密钥对生成 http://web.chacuo.net/netrsakeypair

const publicKey = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCG9t+VR8IF/Oc3QC1H4FuiLMxp44VvGmzouPTH+9jUinD539qxlTZQ031FN5MTGmSKnFGFtc1qgRKxD5Zz1DYobn0UkjxqDDfsmFKhKDETLl68ceJvy2/Od2KhTeJst5O6YjGEV8C5A5YYA9CexgVWDj4r0poLSdnXePFnPSnQiwIDAQAB'
// const publicKey = 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANL378k3RiZHWx5AfJqdH9xRNBmD9wGD\n' +
//   '2iRe41HdTNF8RUhNnHit5NpMNtGL0NPTSSpPjjI1kJfVorRvaQerUgkCAwEAAQ=='

const privateKey = 'MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAJiYa/5z/juhE91xQOTbREVl4SBahlSZgjmRcmN04FJIM5lTEo9drYI0/1yX+/y3znM+QRY33fEyTXe8wp7xdy+5Dzb9WKNXUeNfcsUECSa+w8CIQKI5sRNRDLE4H/sJ1XMWoo1WwEhgsjibJF2oYfq+t/LGEf9cz0fG+CiIlc2zAgMBAAECgYBAPqv5DUzUPhTm/m+b6tTrguEthe9YXuj848eNJ//ppIxU2SzPP1l1oGqCyVpGI/y/eE5e1FaU3eDPsKEf2fmbarVetG+BxmI7KKOXB8allcB4Yk6N3Xns94cG5JdRcJvyBhQR0QOLo0fQP789YsaCsGHodCDmZvZjNaRXy221QQJBAPu3mdZBNI64HEljeGus+6xrXp6FTHw1QvcFWSvslfxHK53kfZR5vYvJEVqYG0h19bI2WqIGA7b+8JxxBLfRgT8CQQCbMRQLICI0HVz+K83v5GUAB6TDcRvhyAUJm0mwU9ldAApwvm8EEBe4c2aR1A+WJNMuKVVuaDhwU+uT20KL6OKNAkAgcopiFAWyYAlFbI0ZVDMdBrortQMm/7aiIQ5dmyG6Y3I76DhH62mDm2ehRfo+XPZPArKsMBpKfJKHmAoDp/4BAkAt/cdw3J8GTsVmVdj8BPWhoqJDgVu/96T2idy2ssKx+vcdHnKMA7Dj6t80zGGqH1OuVHWK+LvxHg2sjcgU6nlpAkEAyOMWdPRyN/Zewelv4bbaPCEmxgsRFBWA4pXU1Qfj2iRsNqGLBkIK2WKXsCf/jnaa2KJitl0GHTE8YdysBzLlwA=='


// 加密
export function encrypt(txt) {
	const encryptor = new JSEncrypt.JSEncrypt()
	encryptor.setPublicKey(publicKey) // 设置公钥
	return encryptor.encrypt(txt) // 对需要加密的数据进行加密
}
// 解密
export function decrypt(txt) {
	const encryptor = new JSEncrypt.JSEncrypt()
	encryptor.setPrivateKey(privateKey)
	return encryptor.decrypt(txt)
}
